
/**
 * From QT OpenGL demo: boxes
 */


#ifndef M3D_TRACKBALL_H
#define M3D_TRACKBALL_H

#include "math3d.h" //use vector3d and quaternion
#include "mpoint.h"
#include "mtime.h"


M3D_BEGIN_NAMESPACE

#define PI 3.14159265358979

class TrackBall
{
public:
    TrackBall();
    TrackBall(float angularVelocity, const MVector3D& axis);

    void push(const MPointF& p);
    void move(const MPointF& p);
    void release(const MPointF& p);
    void start(); // starts clock
    void stop(); // stops clock
    MQuaternion rotation() const;

private:
    MQuaternion m_rotation;
    MVector3D m_axis;
    float m_angularVelocity;

    MPointF m_lastPos;
    MTime m_lastTime;
    bool m_paused;
    bool m_pressed;

};

M3D_END_NAMESPACE

#endif  //end of M3D_MATH3D_H_
